package avicit.bdp.dgs.qa.utils.enums;

/**
 * @金航数码科技有限责任公司
 * @作者：developer
 * @邮箱：developer@avic-digital.com
 * @创建时间： 2023-03-15
 * @类说明：CheckMode
 * @修改记录：
 * @注意事项：
 * @主要功能：校验方式
 */
public enum CheckMode {
    FIXED(0, "与固定值比较"),
    VOLATILITY_AVG_7(1, "7天平均值波动"),
    VOLATILITY_AVG_30(2, "30天平均值波动"),
    VOLATILITY_PER_1(3, "1天周期比较"),
    VOLATILITY_PER_7(4, "7天周期比较"),
    VOLATILITY_PER_30(5, "30天周期比较"),
    VOLATILITY_VAR_7(6, "7天方差比较"),
    VOLATILITY_VAR_30(7, "30天方差比较"),
    VOLATILITY_1_7_30(8, "1.7.30天波动检测"),
    VOLATILITY_PREV(9, "上一周期比价");

    private final int code;

    private final String desc;

    CheckMode(int code, String desc){
        this.code = code;
        this.desc = desc;
    }

    public int getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    public static String getDescByCode(Integer code) {
        if (code != null) {
            CheckMode[] values = CheckMode.values();
            for (CheckMode resourceType : values) {
                if (resourceType.getCode() == code) {
                    return resourceType.getDesc();
                }
            }
        }

        return null;
    }

    public static CheckMode getTypeByCode(Integer code) {
        if (code != null) {
            CheckMode[] values = CheckMode.values();
            for (CheckMode resourceType : values) {
                if (resourceType.getCode() == code) {
                    return resourceType;
                }
            }
        }

        return null;
    }
}
